home *** CD-ROM | disk | FTP | other *** search
/ Network PC / Network PC.iso / amiga utilities / communication / internet / amitcp3.0b / src.lha / src / amitcp / sys / malloc.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-09-08  |  5.9 KB  |  169 lines

  1. /*
  2.  * $Id: malloc.h,v 1.15 1994/03/29 20:06:10 jraja Exp $
  3.  *
  4.  * HISTORY
  5.  * $Log: malloc.h,v $
  6.  * Revision 1.15  1994/03/29  20:06:10  jraja
  7.  * Added macros to prevent passing of unnecessary arguments.
  8.  *
  9.  * Revision 1.14  1994/03/26  10:04:07  too
  10.  * Moved bsd_malloc() and bsd_free() inline functions to kern/kern_malloc.c
  11.  * (now normal functions). Added prototype for bsd_realloc().
  12.  *
  13.  * Revision 1.13  1993/05/16  23:15:36  ppessi
  14.  * Added M_ARPENT
  15.  *
  16.  * Revision 1.12  1993/04/28  22:09:44  ppessi
  17.  * Added M_CFGVAR and M_NETDB as new memory types.
  18.  *
  19.  * Revision 1.11  93/03/11  19:40:33  19:40:33  jraja (Jarno Tapio Rajahalme)
  20.  * Changed mallocSemaphore to malloc_semaphore.
  21.  * 
  22.  * Revision 1.10  93/03/11  12:27:44  12:27:44  jraja (Jarno Tapio Rajahalme)
  23.  * Minor Clean up.
  24.  * 
  25.  * Revision 1.9  93/03/03  19:35:24  19:35:24  jraja (Jarno Tapio Rajahalme)
  26.  * Cleanup. Removed redundant memory types, changed _MALLOC_H_ to SYS_MALLOC_H.
  27.  * 
  28.  * Revision 1.8  93/02/27  12:07:44  12:07:44  ppessi (Pekka Pessi)
  29.  * Added memory type for network interface (M_IFNET)
  30.  * 
  31.  * Revision 1.7  93/02/27  12:05:52  12:05:52  jraja (Jarno Tapio Rajahalme)
  32.  * Added #include <cdefs.h> for inline functions.
  33.  * 
  34.  * Revision 1.6  93/02/24  12:56:09  12:56:09  jraja (Jarno Tapio Rajahalme)
  35.  * Changed malloc_init prototype.
  36.  * 
  37.  * Revision 1.5  93/02/24  11:15:41  11:15:41  jraja (Jarno Tapio Rajahalme)
  38.  * Changed path uxkern to kern.
  39.  * 
  40.  * Revision 1.4  93/01/23  22:21:32  22:21:32  jraja (Jarno Tapio Rajahalme)
  41.  * Protected calls to malloc() & free() with a semaphore (because they are
  42.  * not re-entrant).
  43.  * 
  44.  * Revision 1.3  93/01/06  19:11:56  19:11:56  jraja (Jarno Tapio Rajahalme)
  45.  * Removed all definitions related to virtual memory subsystem.
  46.  * Added inline definitions for bsd_malloc and bsd_free.
  47.  * 
  48.  * Revision 1.2  92/11/20  15:56:56  15:56:56  jraja (Jarno Tapio Rajahalme)
  49.  * Added #ifndef AMITCP's to make this compile.
  50.  * 
  51.  * Revision 1.1  92/11/20  15:47:59  15:47:59  jraja (Jarno Tapio Rajahalme)
  52.  * Initial revision
  53.  */
  54.  
  55. /*
  56.  * Copyright (c) 1987 Regents of the University of California.
  57.  * All rights reserved.
  58.  *
  59.  * Redistribution and use in source and binary forms, with or without
  60.  * modification, are permitted provided that the following conditions
  61.  * are met:
  62.  * 1. Redistributions of source code must retain the above copyright
  63.  *    notice, this list of conditions and the following disclaimer.
  64.  * 2. Redistributions in binary form must reproduce the above copyright
  65.  *    notice, this list of conditions and the following disclaimer in the
  66.  *    documentation and/or other materials provided with the distribution.
  67.  * 3. All advertising materials mentioning features or use of this software
  68.  *    must display the following acknowledgement:
  69.  *    This product includes software developed by the University of
  70.  *    California, Berkeley and its contributors.
  71.  * 4. Neither the name of the University nor the names of its contributors
  72.  *    may be used to endorse or promote products derived from this software
  73.  *    without specific prior written permission.
  74.  *
  75.  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  76.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  77.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  78.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  79.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  80.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  81.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  82.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  83.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  84.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  85.  * SUCH DAMAGE.
  86.  *
  87.  *    @(#)malloc.h    7.25 (Berkeley) 5/15/91
  88.  */
  89.  
  90. #ifndef SYS_MALLOC_H
  91. #define    SYS_MALLOC_H
  92.  
  93. /*
  94.  * flags to malloc
  95.  */
  96. #define    M_WAITOK    0x0000
  97. #define    M_NOWAIT    0x0001
  98.  
  99. /*
  100.  * Types of memory to be allocated
  101.  */
  102. #define    M_FREE        0    /* should be on free list */
  103. #define    M_MBUF        1    /* mbuf */
  104. #define    M_SOCKET    2    /* socket structure */
  105. #define    M_PCB        3    /* protocol control block */
  106. #define    M_RTABLE    4    /* routing tables */
  107. #define    M_HTABLE    5    /* IMP host tables */
  108. #define    M_FTABLE    6    /* fragment reassembly header */
  109. #define    M_IFADDR    7    /* interface address */
  110. #define    M_SOOPTS    8     /* socket options */
  111. #define    M_SONAME    9     /* socket name */
  112. #define    M_IOCTLOPS    10    /* ioctl data buffer */
  113. #define    M_FILEDESC    11    /* Open file descriptor table */
  114. #define    M_TEMP        12    /* misc temporary data buffers */
  115. #define    M_IFNET        13    /* network interface structure */
  116. #define M_CFGVAR     14    /* configureable variable */
  117. #define M_NETDB      15    /* netdb node */
  118. #define M_ARPENT        16    /* ARP entry */
  119. #define    M_LAST        17
  120.  
  121. #ifdef KERNEL
  122.  
  123. /*
  124.  * Use malloc & free of the standard library.
  125.  *
  126.  * NOTE: Because these are called from different tasks concurrently, these
  127.  * have to be protected with a mutex.
  128.  */
  129. #ifndef AMIGA_INCLUDES_H
  130. #include <kern/amiga_includes.h>
  131. #endif
  132.  
  133. #ifndef SYS_CDEFS_H
  134. #include <sys/cdefs.h>
  135. #endif
  136.  
  137. /*
  138.  * prototype for the initialization function
  139.  */
  140. BOOL malloc_init(void);
  141.  
  142. /*
  143.  * prototypes for BSD malloc wrapper functions.
  144.  */
  145.  
  146. #ifndef USE_MALLOC_TYPE_TRACKING
  147. /*
  148.  * These macros are used to prevent unnecessary passing of arguments, which 
  149.  * are currently not used.
  150.  */
  151. #define bsd_malloc(size, type, flags) bsd_malloc(size)
  152. #define bsd_free(addr, type) bsd_free(addr)
  153. #define bsd_realloc(mem, size, type, flags) bsd_realloc(mem, size)
  154. #endif
  155.  
  156. void *    bsd_malloc(unsigned long size, int type, int flags);
  157. void    bsd_free(void *addr, int type);
  158. void *    bsd_realloc(void * mem, unsigned long size, int type, int flags);
  159.  
  160. /*
  161.  * Macro versions for the usual cases of malloc/free
  162.  */
  163. #define    MALLOC(space, cast, size, type, flags) \
  164.     (space) = (cast)bsd_malloc((u_long)(size), type, flags)
  165. #define FREE(addr, type) bsd_free((caddr_t)(addr), type)
  166.  
  167. #endif /* KERNEL */
  168. #endif /* !SYS_MALLOC_H */
  169.